<%-- 
    Document   : basket
    Created on : 08-déc.-2011, 10:15:38
    Author     : laurent
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <fmt:setBundle basename="packageLanguage.lang" scope="session"/>       
        <meta name="keywords" content="" />
        <meta name="description" content="" />
        <link href="css/tempstyle.css" rel="stylesheet" type="text/css" media="screen" />

        <title><fmt:message key = "textWindowCart"/></title>
    </head>
    
    <body>
        <div id="wrapper">
            <div id="logo">
              <jsp:include page="header.jsp"/>  
            </div>
            <hr />
            <!-- end #logo -->
            <div id="header">
		<div id="menu">
			<ul>
				<li><a href="index.jsp" class="first"><fmt:message key = "textFooterHome"/></a></li>
            			<li><a href="CatalogController"><fmt:message key = "textFooterArticles"/></a></li>
				<li><a href="about.jsp"><fmt:message key = "textFooterAbout"/></a></li>
				<li><a href="contact.jsp"><fmt:message key = "textFooterContact"/></a></li>
			</ul>
		</div>
		<!-- end #menu -->
            </div>
        
            <div id="page">
                <div id="page-bgtop">
                    <c:set var="pagename" scope="request" value="basket.jsp"/>
                    <jsp:include page="langpanel.jsp"></jsp:include>

                    <div id="content">
                        <div class="post">
                            
                            
                             <h2 class="title"><fmt:message key = "textTitleBasket"/></h2>
                             <div class="entry">
                                 
                                 <!-- DEBUT SI PANIER NON VIDE -->
                                 <c:if test = "${sessionScope.basket.hashProductsLine.size()  !=  0}">
     
                                     <form name="formBasket" action="BasketController" method="POST">
                                         <input type="hidden" name="selectedProduct"/>

                                         <table border ="1" class="basket">

                                             <tr> 
                                                 <th width="40%"><fmt:message key="textProduct"/></th> 
                                                 <th width="15%" align="center"><fmt:message key="textUnitPrice" /></th>
                                                 <th width="15%" align="center"><fmt:message key="textTotalPrice" /></th>
                                                 <th width="15%" align="center"><fmt:message key="textAmount" /></th>
                                                 <th width="15%" align="center"></th>
                                             </tr>    

                                             <c:forEach var = "productLine" items = "${sessionScope.basket.hashProductsLine}" >
                                                 <tr>
                                                     <td>${productLine.value.product.name}</td>
                                                     <td align="center">${productLine.value.priceUnit} €</td>
                                                     <td align="center">${productLine.value.priceTot} €</td>
                                                     <td align="center">
                                                         <select name="selectedQuantity${productLine.value.product.id}" onChange="document.formBasket.selectedProduct.value = ${productLine.value.product.id}; document.formBasket.submit();">    
                                                            <c:forEach var="i" begin="1" end="20">
                                                                 <option value ="${i}" <c:if test = "${i == productLine.value.nbProducts}">selected="selected"</c:if>>${i}</option>
                                                            </c:forEach>
                                                         </select>
                                                     </td>
                                                     <td>
                                                         <input type="submit" value="<fmt:message key="textDelete" />" name ="delete${productLine.value.product.id}" onClick="if(window.confirm('<fmt:message key="textRemoveThisArticle"/> ?')) { document.formBasket.selectedProduct.value = ${productLine.value.product.id}; document.formOrder.submit(); } else return false;"/>      

                                                     </td>       
                                                 </tr>
                                             </c:forEach >

                                        </table>


                                     </form>
                                         
                                     <br/><br/> 
                                     
                                     <c:if test= "${not empty sessionScope.basket.user}">
                                        <form name="formOrder" action ="OrderController" method="POST">
                                            <input type="submit" value="<fmt:message key="textOrder"/>" name="order" onClick="document.formOrder.submit();"/>            
                                        </form>
                                     </c:if>
                                     <c:if test= "${empty sessionScope.basket.user}">
                                         <fmt:message key="textLoginBeforeOrdering" />
                                     </c:if>
                                 </c:if>
                                 <!-- FIN SI PANIER NON VIDE -->
                                 
                                 <!-- DEBUT SI PANIER VIDE -->
                                 <c:if test= "${sessionScope.basket.hashProductsLine.size()  ==  0}">
                                     <fmt:message key="textYourCartIsEmpty" />
                                 </c:if>
                                 <!-- FIN SI PANIER VIDE -->
                                
                             </div>
                        </div>
                    </div>
                             
                </div>              
            </div>
                             
            <jsp:include page="footer.jsp"></jsp:include> 
            
        </div>
    </body>
</html>
